package de.jabc.sib.bio.ebi;

import de.jabc.adapter.bio.ebi.Branches;
import de.jabc.adapter.bio.ebi.LightweightServiceAdapter;
import de.jabc.adapter.bio.ebi.ServiceAdapter;
import de.metaframe.jabc.framework.execution.ExecutionEnvironment;
import de.metaframe.jabc.framework.sib.annotation.SIBClass;
import de.metaframe.jabc.framework.sib.annotation.SIBStatus;
import de.metaframe.jabc.framework.sib.parameter.ContextExpression;
import de.metaframe.jabc.framework.sib.parameter.ContextKey;
import de.metaframe.jabc.sib.ServiceAdapterDescriptor;

/**
 * Calls the EBI's NCBI BLAST service.
 * 
 * @author anna-lena
 * @version $Revision: 3325 $ $Date: 2008-03-03 13:34:38 +0100 (Mon, 03 Mar
 *          2008) $
 */
@SIBClass("ebi-sibs/NcbiBlast")
@SIBStatus("IMPLEMENTED")
public class NcbiBlast extends AbstractSIB {

	/* Branches */
	public static final String[] BRANCHES = { Branches.DEFAULT, Branches.ERROR };

	/* Parameters */
	public ContextExpression Email = new ContextExpression("", String.class,
			false);
	public ContextExpression Title = new ContextExpression("", String.class,
			false);
	public ContextExpression Program = new ContextExpression("", String.class,
			false);
	public ContextExpression Matrix = new ContextExpression("", String.class,
			false);
	public ContextExpression Alignments = new ContextExpression("",
			String.class, false);
	public ContextExpression Scores = new ContextExpression("", String.class,
			false);
	public ContextExpression Exp = new ContextExpression("", String.class,
			false);
	public ContextExpression Dropoff = new ContextExpression("", String.class,
			false);
	public ContextExpression Match_scores = new ContextExpression("",
			String.class, false);
	public ContextExpression Gapopen = new ContextExpression("", String.class,
			false);
	public ContextExpression Gapext = new ContextExpression("", String.class,
			false);
	public ContextExpression Filter = new ContextExpression("", String.class,
			false);
	public ContextExpression Seqrange = new ContextExpression("", String.class,
			false);
	public ContextExpression Gapalign = new ContextExpression("", String.class,
			false);
	public ContextExpression Align = new ContextExpression("", String.class,
			false);
	public ContextExpression Stype = new ContextExpression("", String.class,
			false);
	public ContextExpression Sequence = new ContextExpression("", String.class,
			false);
	public ContextExpression Database = new ContextExpression("", String.class,
			false);
	public ContextKey resultOut = new ContextKey("result_out", ContextKey.Scope.LOCAL,
			true);
	public ContextKey resultSequence = new ContextKey("result_sequence", ContextKey.Scope.LOCAL,
			true);
	public ContextKey resultIDs = new ContextKey("result_ids", ContextKey.Scope.LOCAL,
			true);
	public ContextKey resultXml = new ContextKey("result_xml", ContextKey.Scope.LOCAL,
			true);

	/**
	 * @see de.metaframe.jabc.sib.CodeGeneratorBlock#execute(ExecutionEnvironment)
	 */
	public String execute(ExecutionEnvironment environment) {
		try {
			return ServiceAdapter.callNcbiBlast(environment, this.Email,
					this.Title, this.Program, this.Matrix, this.Alignments,
					this.Scores, this.Exp, this.Dropoff, this.Match_scores,
					this.Gapopen, this.Gapext, this.Filter, this.Seqrange,
					this.Gapalign, this.Align, this.Stype, this.Sequence,
					this.Database, this.resultOut, this.resultSequence, this.resultIDs, this.resultXml);
		} catch (NoClassDefFoundError e) {
			return Branches.ERROR;
		}
	}

	/**
	 * @see de.metaframe.jabc.sib.Generatable#generate()
	 */
	public ServiceAdapterDescriptor generate() {
		return new ServiceAdapterDescriptor(LightweightServiceAdapter.class
				.getName(), "callNcbiBlast", "Email", "Title", "Program",
				"Matrix", "Alignments", "Scores", "Exp", "Dropoff",
				"Match_scores", "Gapopen", "Gapext", "Filter", "Seqrange",
				"Gapalign", "Align", "Stype", "Sequence", "Database", "resultOut", "resultSequence", "resultIDs", "resultXml");
	}

}
